package demo.liu.one.controller;

import demo.liu.one.fegin.IDemoTwoClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName TestWebsocketController
 * @Description 测试websocket
 * @Author Liujt
 * @Date 2019/12/3 14:19
 **/
@Slf4j
@RefreshScope
@RestController
@RequestMapping("test")
public class TestController {

    //@Value("${test.refreshScope}")
    private String testRefreshScope;

    @Resource
    private IDemoTwoClient iDemoClient;

    @GetMapping("refreshScope")
    public Map testRefreshScope() {
        log.info(">>>>>>>>开始远程调用<<<<<<<<");
        return new HashMap() {{
            this.put("msg", testRefreshScope);
        }};
    }

    @GetMapping("feign")
    public Map testFeign() {
        return iDemoClient.testFeign();
    }

    @GetMapping("test")
    public Map testGroup(@RequestParam("status") Integer status) throws Exception {
        log.error("-------------->str:{}", status);
        if (ObjectUtils.equals(status, 0)) {
            Thread.sleep(50000);
        }
        return new HashMap() {{
            this.put("msg", "看不见，看不见我！！！");
        }};
    }


}
